<?php   // $Id: refu_devis.php 175 2008-05-03 16:52:24Z pcoustillas $ ?>
<?php   
/*Copyright (C) 2003-2004 Guy Hendrickx
Licensed under the terms of the GNU  General Public License:http://www.opensource.org/licenses/gpl-license.php
File Authors:Guy Hendrickx
Modification : Pierre Coustillas*/

$type_verif="devis"; //pour vérifier que l'utisateur à le droit de valider ce devis
$num_doc=$_GET['num_dev']; //pour vérifier que l'utisateur à le droit de valider ce devis
require_once(dirname(__FILE__) ."/verif_client.php");
require_once("../include/utils.php");
require_once("../include/config/common.php");
require_once("../include/config/var.php");
require_once("../include/language/$lang.php");

$conf_xml=simplexml_load_file(dirname(__FILE__) . '/../include/config.xml');
$theme=$conf_xml->generale->theme;

$num_dev=isset($_GET['num_dev'])?$_GET['num_dev']:"";
$login=isset($_GET['login'])?$_GET['login']:"";


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
  <head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Connection à OpenDCF</title>
	<link rel="stylesheet" type="text/css" href="../include/themes/<?php echo "$theme";?>/style.css" />
	<link rel="shortcut icon" type="image/x-icon" href="../image/favicon.ico" />

</head>

<body>

<br/>
<br/>

<center>
<form action="refu_devis_suite.php" method="post">
	<table width="760" border="0" align="center">
		<caption>Refuser le devis n° <?php echo "$num_dev"; ?></caption>
		<tr>
			<th><?php echo $lang_quantite ;?></th>
			<th><?php echo $lang_unite ;?></th>
			<th><?php echo $lang_article ;?></th>
			<th><?php echo $lang_montant_htva ;?></th>
		</tr>
		<?php
		$sql2 = "SELECT ${tblpref}cont_dev.num, uni, quanti, article, tot_art_htva FROM ${tblpref}cont_dev RIGHT JOIN
					${tblpref}article on ${tblpref}cont_dev.article_num = ${tblpref}article.num WHERE dev_num=$num_dev";
		$req = mysql_query($sql2) or die("Erreur selection devis !<br/>$sql2<br/>" . mysql_error());
		
		while($data = mysql_fetch_array($req))
		{
		$quanti = $data['quanti'];
		$uni = $data['uni'];
		$article = $data['article'];
		$tot = $data['tot_art_htva'];
		$num_cont = $data['num'];
		?>
		<tr>
			<td class ='<?php echo couleur_alternee (TRUE); ?>' style="text-align:right"><?php echo $quanti ?></td>
			<td class ='<?php echo couleur_alternee (FALSE); ?>'><?php echo $uni  ?></td>
			<td class ='<?php echo couleur_alternee (FALSE); ?>'><?php echo $article ?></td>
			<td class ='<?php echo couleur_alternee (FALSE); ?>' style="text-align:right"><?php echo "$tot $devise" ?></td>
		</tr>
		<?php   }

		//on calcule la somme des contenus du bon
		$sql = " SELECT SUM(tot_art_htva) FROM ${tblpref}cont_dev WHERE dev_num=$num_dev";
		$result = mysql_query($sql) or die("Erreur calcul sum HT !<br/>$sql<br/>" . mysql_error());
		$total_bon = mysql_result($result,0);
	
		//on calcule la some de la tva des contenus du bon
		$sql = " SELECT SUM(to_tva_art) FROM ${tblpref}cont_dev WHERE dev_num=$num_dev";
		$result = mysql_query($sql) or die("Erreur SQL !<br/>$sql<br/>" . mysql_error());
		$total_tva = mysql_result($result,0);

		?>
		<tr>
			<td colspan="4"><hr/></td>
		</tr>

		<tr>
			<td class='totalmontant'><?php echo "$lang_total" ?></td>
			<td class='totalmontant'><?php echo "$total_bon $devise" ?></td>
			<td class='totalmontant'><?php echo "$lang_tva" ?></td>
			<td class='totalmontant'><?php echo "$total_tva $devise" ?></td>
		</tr>

		<tr>
			<td colspan="4">&nbsp;</td>
		</tr>

		<tr>
			<td class="grand" colspan="2" style="vertical-align:middle;text-align:center">
				<?php aff_lang("Merci d'ajouter un message") ?>
			</td>
			<td class="texte0" colspan="2"><textarea rows="10" cols="40" name="message"></textarea></td>
		</tr>
		<tr>
			<td colspan="3">
				<center>
					<input type="hidden" name="login" value ='<?php echo "$login" ?>' />
					<input type="hidden" name="num_dev" value ='<?php echo "$num_dev" ?>' />
					<input type="submit" value="      <?php aff_lang("Refuser ce devis") ?>      " />
				</center>
			</td>
			<td>
				<center>
					<input type="reset" value="<?php echo $lang_annuler; ?>" />
				</center>
			</td>
		</tr>
  </table>
</form>
</center>

</body>


</html>

